<?php


abstract class BaseFunc_familia extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $numhistoria;


	
	protected $desiciones;


	
	protected $defectos;


	
	protected $ayudan;


	
	protected $armonia;


	
	protected $responsa;


	
	protected $tareas;


	
	protected $temas;

	
	protected $aHistoria;

	
	protected $aFrecuenciaRelatedByDesiciones;

	
	protected $aFrecuenciaRelatedByDefectos;

	
	protected $aFrecuenciaRelatedByAyudan;

	
	protected $aFrecuenciaRelatedByArmonia;

	
	protected $aFrecuenciaRelatedByResponsa;

	
	protected $aFrecuenciaRelatedByTareas;

	
	protected $aFrecuenciaRelatedByTemas;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getNumhistoria()
	{

		return $this->numhistoria;
	}

	
	public function getDesiciones()
	{

		return $this->desiciones;
	}

	
	public function getDefectos()
	{

		return $this->defectos;
	}

	
	public function getAyudan()
	{

		return $this->ayudan;
	}

	
	public function getArmonia()
	{

		return $this->armonia;
	}

	
	public function getResponsa()
	{

		return $this->responsa;
	}

	
	public function getTareas()
	{

		return $this->tareas;
	}

	
	public function getTemas()
	{

		return $this->temas;
	}

	
	public function setId($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = Func_familiaPeer::ID;
		}

	} 
	
	public function setNumhistoria($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->numhistoria !== $v) {
			$this->numhistoria = $v;
			$this->modifiedColumns[] = Func_familiaPeer::NUMHISTORIA;
		}

		if ($this->aHistoria !== null && $this->aHistoria->getNumhistoria() !== $v) {
			$this->aHistoria = null;
		}

	} 
	
	public function setDesiciones($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->desiciones !== $v) {
			$this->desiciones = $v;
			$this->modifiedColumns[] = Func_familiaPeer::DESICIONES;
		}

		if ($this->aFrecuenciaRelatedByDesiciones !== null && $this->aFrecuenciaRelatedByDesiciones->getId() !== $v) {
			$this->aFrecuenciaRelatedByDesiciones = null;
		}

	} 
	
	public function setDefectos($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->defectos !== $v) {
			$this->defectos = $v;
			$this->modifiedColumns[] = Func_familiaPeer::DEFECTOS;
		}

		if ($this->aFrecuenciaRelatedByDefectos !== null && $this->aFrecuenciaRelatedByDefectos->getId() !== $v) {
			$this->aFrecuenciaRelatedByDefectos = null;
		}

	} 
	
	public function setAyudan($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->ayudan !== $v) {
			$this->ayudan = $v;
			$this->modifiedColumns[] = Func_familiaPeer::AYUDAN;
		}

		if ($this->aFrecuenciaRelatedByAyudan !== null && $this->aFrecuenciaRelatedByAyudan->getId() !== $v) {
			$this->aFrecuenciaRelatedByAyudan = null;
		}

	} 
	
	public function setArmonia($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->armonia !== $v) {
			$this->armonia = $v;
			$this->modifiedColumns[] = Func_familiaPeer::ARMONIA;
		}

		if ($this->aFrecuenciaRelatedByArmonia !== null && $this->aFrecuenciaRelatedByArmonia->getId() !== $v) {
			$this->aFrecuenciaRelatedByArmonia = null;
		}

	} 
	
	public function setResponsa($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->responsa !== $v) {
			$this->responsa = $v;
			$this->modifiedColumns[] = Func_familiaPeer::RESPONSA;
		}

		if ($this->aFrecuenciaRelatedByResponsa !== null && $this->aFrecuenciaRelatedByResponsa->getId() !== $v) {
			$this->aFrecuenciaRelatedByResponsa = null;
		}

	} 
	
	public function setTareas($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->tareas !== $v) {
			$this->tareas = $v;
			$this->modifiedColumns[] = Func_familiaPeer::TAREAS;
		}

		if ($this->aFrecuenciaRelatedByTareas !== null && $this->aFrecuenciaRelatedByTareas->getId() !== $v) {
			$this->aFrecuenciaRelatedByTareas = null;
		}

	} 
	
	public function setTemas($v)
	{

						if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->temas !== $v) {
			$this->temas = $v;
			$this->modifiedColumns[] = Func_familiaPeer::TEMAS;
		}

		if ($this->aFrecuenciaRelatedByTemas !== null && $this->aFrecuenciaRelatedByTemas->getId() !== $v) {
			$this->aFrecuenciaRelatedByTemas = null;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->numhistoria = $rs->getInt($startcol + 1);

			$this->desiciones = $rs->getInt($startcol + 2);

			$this->defectos = $rs->getInt($startcol + 3);

			$this->ayudan = $rs->getInt($startcol + 4);

			$this->armonia = $rs->getInt($startcol + 5);

			$this->responsa = $rs->getInt($startcol + 6);

			$this->tareas = $rs->getInt($startcol + 7);

			$this->temas = $rs->getInt($startcol + 8);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 9; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Func_familia object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(Func_familiaPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			Func_familiaPeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(Func_familiaPeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aHistoria !== null) {
				if ($this->aHistoria->isModified()) {
					$affectedRows += $this->aHistoria->save($con);
				}
				$this->setHistoria($this->aHistoria);
			}

			if ($this->aFrecuenciaRelatedByDesiciones !== null) {
				if ($this->aFrecuenciaRelatedByDesiciones->isModified()) {
					$affectedRows += $this->aFrecuenciaRelatedByDesiciones->save($con);
				}
				$this->setFrecuenciaRelatedByDesiciones($this->aFrecuenciaRelatedByDesiciones);
			}

			if ($this->aFrecuenciaRelatedByDefectos !== null) {
				if ($this->aFrecuenciaRelatedByDefectos->isModified()) {
					$affectedRows += $this->aFrecuenciaRelatedByDefectos->save($con);
				}
				$this->setFrecuenciaRelatedByDefectos($this->aFrecuenciaRelatedByDefectos);
			}

			if ($this->aFrecuenciaRelatedByAyudan !== null) {
				if ($this->aFrecuenciaRelatedByAyudan->isModified()) {
					$affectedRows += $this->aFrecuenciaRelatedByAyudan->save($con);
				}
				$this->setFrecuenciaRelatedByAyudan($this->aFrecuenciaRelatedByAyudan);
			}

			if ($this->aFrecuenciaRelatedByArmonia !== null) {
				if ($this->aFrecuenciaRelatedByArmonia->isModified()) {
					$affectedRows += $this->aFrecuenciaRelatedByArmonia->save($con);
				}
				$this->setFrecuenciaRelatedByArmonia($this->aFrecuenciaRelatedByArmonia);
			}

			if ($this->aFrecuenciaRelatedByResponsa !== null) {
				if ($this->aFrecuenciaRelatedByResponsa->isModified()) {
					$affectedRows += $this->aFrecuenciaRelatedByResponsa->save($con);
				}
				$this->setFrecuenciaRelatedByResponsa($this->aFrecuenciaRelatedByResponsa);
			}

			if ($this->aFrecuenciaRelatedByTareas !== null) {
				if ($this->aFrecuenciaRelatedByTareas->isModified()) {
					$affectedRows += $this->aFrecuenciaRelatedByTareas->save($con);
				}
				$this->setFrecuenciaRelatedByTareas($this->aFrecuenciaRelatedByTareas);
			}

			if ($this->aFrecuenciaRelatedByTemas !== null) {
				if ($this->aFrecuenciaRelatedByTemas->isModified()) {
					$affectedRows += $this->aFrecuenciaRelatedByTemas->save($con);
				}
				$this->setFrecuenciaRelatedByTemas($this->aFrecuenciaRelatedByTemas);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = Func_familiaPeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += Func_familiaPeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aHistoria !== null) {
				if (!$this->aHistoria->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aHistoria->getValidationFailures());
				}
			}

			if ($this->aFrecuenciaRelatedByDesiciones !== null) {
				if (!$this->aFrecuenciaRelatedByDesiciones->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aFrecuenciaRelatedByDesiciones->getValidationFailures());
				}
			}

			if ($this->aFrecuenciaRelatedByDefectos !== null) {
				if (!$this->aFrecuenciaRelatedByDefectos->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aFrecuenciaRelatedByDefectos->getValidationFailures());
				}
			}

			if ($this->aFrecuenciaRelatedByAyudan !== null) {
				if (!$this->aFrecuenciaRelatedByAyudan->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aFrecuenciaRelatedByAyudan->getValidationFailures());
				}
			}

			if ($this->aFrecuenciaRelatedByArmonia !== null) {
				if (!$this->aFrecuenciaRelatedByArmonia->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aFrecuenciaRelatedByArmonia->getValidationFailures());
				}
			}

			if ($this->aFrecuenciaRelatedByResponsa !== null) {
				if (!$this->aFrecuenciaRelatedByResponsa->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aFrecuenciaRelatedByResponsa->getValidationFailures());
				}
			}

			if ($this->aFrecuenciaRelatedByTareas !== null) {
				if (!$this->aFrecuenciaRelatedByTareas->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aFrecuenciaRelatedByTareas->getValidationFailures());
				}
			}

			if ($this->aFrecuenciaRelatedByTemas !== null) {
				if (!$this->aFrecuenciaRelatedByTemas->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aFrecuenciaRelatedByTemas->getValidationFailures());
				}
			}


			if (($retval = Func_familiaPeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}



			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = Func_familiaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getNumhistoria();
				break;
			case 2:
				return $this->getDesiciones();
				break;
			case 3:
				return $this->getDefectos();
				break;
			case 4:
				return $this->getAyudan();
				break;
			case 5:
				return $this->getArmonia();
				break;
			case 6:
				return $this->getResponsa();
				break;
			case 7:
				return $this->getTareas();
				break;
			case 8:
				return $this->getTemas();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = Func_familiaPeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getNumhistoria(),
			$keys[2] => $this->getDesiciones(),
			$keys[3] => $this->getDefectos(),
			$keys[4] => $this->getAyudan(),
			$keys[5] => $this->getArmonia(),
			$keys[6] => $this->getResponsa(),
			$keys[7] => $this->getTareas(),
			$keys[8] => $this->getTemas(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = Func_familiaPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setNumhistoria($value);
				break;
			case 2:
				$this->setDesiciones($value);
				break;
			case 3:
				$this->setDefectos($value);
				break;
			case 4:
				$this->setAyudan($value);
				break;
			case 5:
				$this->setArmonia($value);
				break;
			case 6:
				$this->setResponsa($value);
				break;
			case 7:
				$this->setTareas($value);
				break;
			case 8:
				$this->setTemas($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = Func_familiaPeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setNumhistoria($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setDesiciones($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setDefectos($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setAyudan($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setArmonia($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setResponsa($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setTareas($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setTemas($arr[$keys[8]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(Func_familiaPeer::DATABASE_NAME);

		if ($this->isColumnModified(Func_familiaPeer::ID)) $criteria->add(Func_familiaPeer::ID, $this->id);
		if ($this->isColumnModified(Func_familiaPeer::NUMHISTORIA)) $criteria->add(Func_familiaPeer::NUMHISTORIA, $this->numhistoria);
		if ($this->isColumnModified(Func_familiaPeer::DESICIONES)) $criteria->add(Func_familiaPeer::DESICIONES, $this->desiciones);
		if ($this->isColumnModified(Func_familiaPeer::DEFECTOS)) $criteria->add(Func_familiaPeer::DEFECTOS, $this->defectos);
		if ($this->isColumnModified(Func_familiaPeer::AYUDAN)) $criteria->add(Func_familiaPeer::AYUDAN, $this->ayudan);
		if ($this->isColumnModified(Func_familiaPeer::ARMONIA)) $criteria->add(Func_familiaPeer::ARMONIA, $this->armonia);
		if ($this->isColumnModified(Func_familiaPeer::RESPONSA)) $criteria->add(Func_familiaPeer::RESPONSA, $this->responsa);
		if ($this->isColumnModified(Func_familiaPeer::TAREAS)) $criteria->add(Func_familiaPeer::TAREAS, $this->tareas);
		if ($this->isColumnModified(Func_familiaPeer::TEMAS)) $criteria->add(Func_familiaPeer::TEMAS, $this->temas);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(Func_familiaPeer::DATABASE_NAME);

		$criteria->add(Func_familiaPeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setNumhistoria($this->numhistoria);

		$copyObj->setDesiciones($this->desiciones);

		$copyObj->setDefectos($this->defectos);

		$copyObj->setAyudan($this->ayudan);

		$copyObj->setArmonia($this->armonia);

		$copyObj->setResponsa($this->responsa);

		$copyObj->setTareas($this->tareas);

		$copyObj->setTemas($this->temas);


		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new Func_familiaPeer();
		}
		return self::$peer;
	}

	
	public function setHistoria($v)
	{


		if ($v === null) {
			$this->setNumhistoria(NULL);
		} else {
			$this->setNumhistoria($v->getNumhistoria());
		}


		$this->aHistoria = $v;
	}


	
	public function getHistoria($con = null)
	{
		if ($this->aHistoria === null && ($this->numhistoria !== null)) {
						$this->aHistoria = HistoriaPeer::retrieveByPK($this->numhistoria, $con);

			
		}
		return $this->aHistoria;
	}

	
	public function setFrecuenciaRelatedByDesiciones($v)
	{


		if ($v === null) {
			$this->setDesiciones(NULL);
		} else {
			$this->setDesiciones($v->getId());
		}


		$this->aFrecuenciaRelatedByDesiciones = $v;
	}


	
	public function getFrecuenciaRelatedByDesiciones($con = null)
	{
		if ($this->aFrecuenciaRelatedByDesiciones === null && ($this->desiciones !== null)) {
						$this->aFrecuenciaRelatedByDesiciones = FrecuenciaPeer::retrieveByPK($this->desiciones, $con);

			
		}
		return $this->aFrecuenciaRelatedByDesiciones;
	}

	
	public function setFrecuenciaRelatedByDefectos($v)
	{


		if ($v === null) {
			$this->setDefectos(NULL);
		} else {
			$this->setDefectos($v->getId());
		}


		$this->aFrecuenciaRelatedByDefectos = $v;
	}


	
	public function getFrecuenciaRelatedByDefectos($con = null)
	{
		if ($this->aFrecuenciaRelatedByDefectos === null && ($this->defectos !== null)) {
						$this->aFrecuenciaRelatedByDefectos = FrecuenciaPeer::retrieveByPK($this->defectos, $con);

			
		}
		return $this->aFrecuenciaRelatedByDefectos;
	}

	
	public function setFrecuenciaRelatedByAyudan($v)
	{


		if ($v === null) {
			$this->setAyudan(NULL);
		} else {
			$this->setAyudan($v->getId());
		}


		$this->aFrecuenciaRelatedByAyudan = $v;
	}


	
	public function getFrecuenciaRelatedByAyudan($con = null)
	{
		if ($this->aFrecuenciaRelatedByAyudan === null && ($this->ayudan !== null)) {
						$this->aFrecuenciaRelatedByAyudan = FrecuenciaPeer::retrieveByPK($this->ayudan, $con);

			
		}
		return $this->aFrecuenciaRelatedByAyudan;
	}

	
	public function setFrecuenciaRelatedByArmonia($v)
	{


		if ($v === null) {
			$this->setArmonia(NULL);
		} else {
			$this->setArmonia($v->getId());
		}


		$this->aFrecuenciaRelatedByArmonia = $v;
	}


	
	public function getFrecuenciaRelatedByArmonia($con = null)
	{
		if ($this->aFrecuenciaRelatedByArmonia === null && ($this->armonia !== null)) {
						$this->aFrecuenciaRelatedByArmonia = FrecuenciaPeer::retrieveByPK($this->armonia, $con);

			
		}
		return $this->aFrecuenciaRelatedByArmonia;
	}

	
	public function setFrecuenciaRelatedByResponsa($v)
	{


		if ($v === null) {
			$this->setResponsa(NULL);
		} else {
			$this->setResponsa($v->getId());
		}


		$this->aFrecuenciaRelatedByResponsa = $v;
	}


	
	public function getFrecuenciaRelatedByResponsa($con = null)
	{
		if ($this->aFrecuenciaRelatedByResponsa === null && ($this->responsa !== null)) {
						$this->aFrecuenciaRelatedByResponsa = FrecuenciaPeer::retrieveByPK($this->responsa, $con);

			
		}
		return $this->aFrecuenciaRelatedByResponsa;
	}

	
	public function setFrecuenciaRelatedByTareas($v)
	{


		if ($v === null) {
			$this->setTareas(NULL);
		} else {
			$this->setTareas($v->getId());
		}


		$this->aFrecuenciaRelatedByTareas = $v;
	}


	
	public function getFrecuenciaRelatedByTareas($con = null)
	{
		if ($this->aFrecuenciaRelatedByTareas === null && ($this->tareas !== null)) {
						$this->aFrecuenciaRelatedByTareas = FrecuenciaPeer::retrieveByPK($this->tareas, $con);

			
		}
		return $this->aFrecuenciaRelatedByTareas;
	}

	
	public function setFrecuenciaRelatedByTemas($v)
	{


		if ($v === null) {
			$this->setTemas(NULL);
		} else {
			$this->setTemas($v->getId());
		}


		$this->aFrecuenciaRelatedByTemas = $v;
	}


	
	public function getFrecuenciaRelatedByTemas($con = null)
	{
		if ($this->aFrecuenciaRelatedByTemas === null && ($this->temas !== null)) {
						$this->aFrecuenciaRelatedByTemas = FrecuenciaPeer::retrieveByPK($this->temas, $con);

			
		}
		return $this->aFrecuenciaRelatedByTemas;
	}

} 